﻿using Exiled.API.Features;
using HarmonyLib;
using RgCore.CustomSide;

namespace CustomCharacter.Patches
{
    [HarmonyPatch(typeof(HitboxIdentity),nameof(HitboxIdentity.IsEnemy), typeof(ReferenceHub), typeof(ReferenceHub))]
    public static class IsEnemyPatch
    {
        [HarmonyPrefix]
        public static bool Prefix(ReferenceHub attacker, ReferenceHub victim, ref bool __result)
        {
            Player atk = Player.Get(attacker);
            Player vic = Player.Get(victim);
            if (atk != null && vic != null)
            {
                __result = !SideManager.IsFriendly(atk, vic);
                return false;
            }
            return true;
        }
    }
}
